
R3F_FNCT_Marker_Player = {
	private ["_list_mark","_new_list_mark","_list_player","_i"];
	if (count _this > 0) then {
		VAR_R3F_Marker_Player = _this select 0;
	} else {
		VAR_R3F_Marker_Player = true;
	};
	_list_mark = [];
	while {VAR_R3F_Marker_Player} do {
		_new_list_mark = [];
		_list_player = switchableUnits + playableUnits;
		for [{_i = 0},{_i < count _list_player},{_i = _i + 1}] do {
			private ["_player","_mark"];
			_player = _list_player select _i;
			if (isPlayer _player && alive _player) then {
				_mark = "mark_" + name _player;
				if (getMarkerPos _mark distance [0, 0] == 0) then {
					_mark = createMarkerLocal [_mark,[0, 0]];
					_mark setMarkerTypeLocal ([_player] call R3F_FNCT_GetMarkerType);
					_mark setMarkerColorLocal ([_player] call R3F_FNCT_GetMarkerColor);
					_mark setMarkerAlphaLocal 0.5;
					_mark setMarkerSizeLocal ([_player] call R3F_FNCT_GetMarkerSize);
					_mark setMarkerTextLocal format [" %1",(name _player)];
				};
				_mark setMarkerPosLocal (getPos (vehicle _player));
				_mark setMarkerDirLocal (getDir (vehicle _player));
				_new_list_mark set [count _new_list_mark,_mark];
			};
			sleep (1/count _list_player);
		};
		{	deleteMarkerLocal _x;
		} forEach (_list_mark - _new_list_mark);
		_list_mark = _new_list_mark;
	};
	{deleteMarkerLocal _x;} forEach _list_mark;
};
R3F_FNCT_ShowIA = {
	private ["_array_mark","_allunits","_mark","_marker_exists","_vehicle","_driver","_array_cargo","_nbr_cargo"];
	if ((count _this) > 0) then {
		VAR_R3F_ShowIA = _this select 0;
	} else {
		VAR_R3F_ShowIA = true;
	};
	if (VAR_R3F_ShowIA) then {
		VAR_R3F_ShowIA = false;
		sleep 0.5;
		VAR_R3F_ShowIA = true;
	};
	_array_mark = [];
	while {VAR_R3F_ShowIA} do {
		_allunits = Allunits;
		{	if (alive _x) then {
				_mark =  str (vehicle _x);
				_marker_exists = [_array_mark,_mark] call R3F_FNCT_IsInArray;
				if (!_marker_exists) then {
					_mark = createMarkerLocal [_mark,[0,0]];
					_mark setMarkerTypeLocal ([_x] call R3F_FNCT_GetMarkerType);
					_mark setMarkerColorLocal ([_x] call R3F_FNCT_GetMarkerColor);
					if !(isPlayer _x) then {_mark setMarkerAlphaLocal 0.7;};
					_mark setMarkerSizeLocal ([_x] call R3F_FNCT_GetMarkerSize);
					_array_mark set [count _array_mark,[_x,_mark]];
					_vehicle = assignedVehicle _x;
				};
				if (assignedVehicle _x != _vehicle) then {
					_mark setMarkerTypeLocal ([_x] call R3F_FNCT_GetMarkerType);
					_mark setMarkerSizeLocal ([_x] call R3F_FNCT_GetMarkerSize);
				};
				if (_x == leader _x) then {
					_mark setMarkerTextLocal ([_x] call R3F_FNCT_GetMarkerText);
				};
				_mark setMarkerPosLocal (getPos (vehicle _x));
				_mark setMarkerDirLocal (getDir (vehicle _x));
			};
		} foreach _allunits;
		sleep 1;
		_array_mark = [_array_mark] call R3F_FNCT_CleanArray;
	};
	[_array_mark] call R3F_FNCT_CleanAllMarker;
};
R3F_FNCT_GetMarkerColor = {
	private ["_unit","_color"];
	_unit = _this select 0;
	if (side _unit == east) then {
		_color = "ColorRed";
	} else {
		if (side _unit == west) then {
			_color = "ColorBlue";
		} else {
			if (side _unit == civilian) then {
				_color = "ColorGreen";
			} else {
				_color = "ColorOrange";
			};
		};
	};
	_color
};
R3F_FNCT_GetMarkerSize = {
	private ["_unit","_size"];
	_unit = _this select 0;
	if ((vehicle _unit) isKindOf "Man") then {
		_size = [0.2,0.2];
	} else {
		if ((vehicle _unit) isKindOf "Land") then {
			_size = [0.2,0.4];
		} else {
			if ((vehicle _unit) isKindOf "Air") then {
				_size = [0.2,0.4];
			} else {
				if ((vehicle _unit) isKindOf "Ship") then {
					_size = [0.3,0.3];
				};
			};
		};
	};
	_size
};
R3F_FNCT_GetMarkerType = {
	private ["_unit","_type"];
	_unit = _this select 0;
	if ((vehicle _unit) isKindOf "Man") then {
		_type = "hd_arrow";
	} else {
		if ((vehicle _unit) isKindOf "Land") then {
			_type = "mil_arrow";
		} else {
			if ((vehicle _unit) isKindOf "Air") then {
				_type = "mil_arrow2";
			} else {
				if ((vehicle _unit) isKindOf "Ship") then {
					_type = "mil_arrow2";
				};
			};
		};
	};
	_type
};
R3F_FNCT_GetMarkerText = {
	private ["_unit","_text"];
	_unit = _this select 0;
	if (_unit == leader _unit) then {
		_driver = assignedDriver (vehicle _unit);
		_array_cargo = assignedCargo (vehicle _unit);
		_nbr_cargo = count _array_cargo;
		if ((((units _unit) select (count units _unit) - 1) in _array_cargo) && (_driver in (units _unit))) then {
			_nbr_cargo = 0;
		};
		_text =  format ["%1",_nbr_cargo + count (units (vehicle _unit))];
	};
	_text
};
R3F_FNCT_CleanAllMarker = {
	private "_array_mark";
	_array_mark = _this select 0;
	{	deleteMarkerLocal (_x select 1);
	} forEach _array_mark;
};
R3F_FNCT_CleanArray = {
	private ["_array","_array_temp","_unit"];
	_array = _this select 0;
	_array_temp = [];
	{	_unit = _x select 0;
		if ((isNull _unit) || !(alive _unit)) then {
			deleteMarkerLocal (_x select 1);
		} else {
			_array_temp set [count _array_temp,_x];
		};
	} foreach _array;
	_array_temp
};
R3F_FNCT_IsInArray = {
	private ["_array","_return","_mark"];
	_array = _this select 0;
	_return = false;
	if (count _array > 0) then {
		_mark = _this select 1;
		{	if (_mark in _x) exitWith {
				_return = true;
			};		
		} foreach _array;
	};
	_return
};
